package net.entelijan.cobean.examples.util;

import java.awt.FileDialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class FileDialogRunner {

	public FileDialogRunner() {
		super();
	}

	public static void main(String[] args) {
		final JFrame frame = new JFrame(FileDialogRunner.class.getName());
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JButton buton = new JButton("Select file");
		buton.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				FileDialog fd = new FileDialog(frame);
				fd.setTitle("Select file");

				fd.setVisible(true);
				System.out.println(fd.getFile());
				System.out.println(fd.getMode());
			}
		});
		frame.getContentPane().add(buton);
		frame.pack();
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				frame.setVisible(true);
			}

		});

	}

}
